﻿using GENERIC.Repository.Tests.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace GENERIC.EFRepository.Tests
{
    public class CustomerMapping : EFMapping<Customer>
    {
        #region Constructeur

        public CustomerMapping()
        {
        }

        #endregion

        #region Properties

        protected override string TableName
        {
            get { return "Customers"; }
        }

        #endregion
        
        #region Methods

        protected override Expression<Func<Customer, object>> GetPrimaryKey()
        {
            return i =>  i.Id;
        }

        protected override void MapProperties()
        {
            Property(i => i.Name).HasColumnName("name").IsRequired().HasMaxLength(10);
            HasMany(i => i.Orders).WithOptional().HasForeignKey(j => j.CustumerId);
        }

        #endregion
    }
}
